<?php
function getSettings(){
	global $db;
	$rows=$db->row_select("settings","",0,"*","property");
	$row=array();
	foreach($rows as $tmprow){
		$row["{$tmprow['property']}"]=$tmprow['setvalue'];
	}
	return $row;
}

function saveSettings($setpp){
	global $db;
	foreach($setpp as $key=>$value){
		$db->query_unbuffered("REPLACE INTO `{$db->pre}settings` (property, setvalue) VALUES ('{$key}','{$value}')");
	}
}


function sizeFormat($filesize, $type='') {
	if($type=='GB') {
		$filesize = round($filesize / 1073741824 * 100) / 100 . ' GB';
	} elseif($type=='MB') {
		$filesize = round($filesize / 1048576 * 100) / 100 . ' MB';
	} elseif($type=='KB') {
		$filesize = round($filesize / 1024 * 100) / 100 . ' KB';
	} elseif($type=='Bytes') {
		$filesize = $filesize . ' Bytes';
	} else {
		if($filesize >= 1073741824) {
			$filesize = round($filesize / 1073741824 * 100) / 100 . ' GB';
		} elseif($filesize >= 1048576) {
			$filesize = round($filesize / 1048576 * 100) / 100 . ' MB';
		} elseif($filesize >= 1024) {
			$filesize = round($filesize / 1024 * 100) / 100 . ' KB';
		} else {
			$filesize = $filesize . ' Bytes';
		}
	}
	return $filesize;
}

?>
